package main.java.com.epam;

public class Transferer implements Runnable {
	
	private RingBuffer readRingBuffer;
	private RingBuffer writeRingBuffer;
	
	public Transferer(RingBuffer readRingBuffer, RingBuffer writeRingBuffer) {
		this.readRingBuffer = readRingBuffer;
		this.writeRingBuffer = writeRingBuffer;
	}
	
	@Override
	public void run() {
		while(true){
			try {
				String message = readRingBuffer.getMessage();
				Thread.yield();
				writeRingBuffer.insertMessage("potok " + Thread.currentThread().getId() + " pereklav povidomlennya " + message);
				Thread.yield(); 
			} catch (InterruptedException e) {
				e.printStackTrace();
			}
		}
	}

}
